package thread;

public class demo6 {

    public static void main(String[] args) throws InterruptedException {
        Thread[] ts = new Thread[20];
        for (int i = 0; i < 20; i++) {
            int k = i;
            ts[i] = new Thread(() -> {
                System.out.println(k);
            });
        }
        for (Thread t: ts) {
            t.start();
        }
        for (Thread t: ts) {
            t.join();
        }
        System.out.println("ok");
    }
}
